package cn.fintecher.pangolin.service.dataimp.model.request;

import cn.fintecher.pangolin.common.enums.FlowType;
import cn.fintecher.pangolin.entity.mysql.QProcessApplication;
import com.querydsl.core.BooleanBuilder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @Author wangxiangdong
 * @Description 导出request
 * @Date 2019/10/17 9:44
 **/
@Data
public class ApprovalExportRequest {

    @ApiModelProperty("流程类别")
    private FlowType flowType;

    @ApiModelProperty("需要导出的id")
    private List<String> processApplicationIds;

    public BooleanBuilder generateBooleanBuilder(){
        BooleanBuilder booleanBuilder = new BooleanBuilder();
        if(Objects.nonNull(flowType)){
            booleanBuilder.and(QProcessApplication.processApplication.flowType.eq(flowType));
        }
        if(Objects.nonNull(processApplicationIds)){
            booleanBuilder.and(QProcessApplication.processApplication.id.in(processApplicationIds));
        }
        return booleanBuilder;
    }
}
